/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package GUI;

import javax.swing.JOptionPane;

/**
 *
 * @author Nordahl
 */
public class CartDA extends javax.swing.JPanel {
    
    tvmGUI master;
    /**
     * Creates new form CartDA
     */
    public CartDA() {
        initComponents();
        //LabCartDATime.setText(master.time.toString().substring(0,19));
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        LabCartDAInfo = new javax.swing.JLabel();
        LabCartDATime = new javax.swing.JLabel();
        LabCartDATitle = new javax.swing.JLabel();
        LabCartDAInstruct = new javax.swing.JLabel();
        LabCartDATotal = new javax.swing.JLabel();
        ButCartDAHelp = new javax.swing.JButton();
        ButCartDAClear = new javax.swing.JButton();
        ButCartDARemove = new javax.swing.JButton();
        ButCartDAAddM = new javax.swing.JButton();
        ButCartDAPay = new javax.swing.JButton();
        jScrollPane2 = new javax.swing.JScrollPane();
        ListCartDATicketList = new javax.swing.JList();
        LabCartDASTK = new javax.swing.JLabel();
        LabCartDKType = new javax.swing.JLabel();
        LabCartDKAmountZones = new javax.swing.JLabel();
        LabCartDKPricePerTicket = new javax.swing.JLabel();
        LabCartDKSubTotal = new javax.swing.JLabel();

        setMinimumSize(new java.awt.Dimension(800, 600));

        LabCartDAInfo.setText(" ");

        LabCartDATime.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
        LabCartDATime.setText(" ");

        LabCartDATitle.setFont(new java.awt.Font("Tahoma", 1, 24)); // NOI18N
        LabCartDATitle.setText("Indkøbskurv");

        LabCartDAInstruct.setText("Herunder kan du se dine valgte billetter. Du kan vælge at slette billetter, tilføje flere, rydde alt, eller gå til betaling. ");

        LabCartDATotal.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        LabCartDATotal.setText("Total pris: ");

        ButCartDAHelp.setText("?");
        ButCartDAHelp.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                ButCartDAHelpActionPerformed(evt);
            }
        });

        ButCartDAClear.setText("Ryd alt");
        ButCartDAClear.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                ButCartDAClearActionPerformed(evt);
            }
        });

        ButCartDARemove.setText("Fjern");
        ButCartDARemove.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                ButCartDARemoveActionPerformed(evt);
            }
        });

        ButCartDAAddM.setText("Tilføj flere");
        ButCartDAAddM.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                ButCartDAAddMActionPerformed(evt);
            }
        });

        ButCartDAPay.setText("Gå til betaling");
        ButCartDAPay.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                ButCartDAPayActionPerformed(evt);
            }
        });

        ListCartDATicketList.setFont(new java.awt.Font("Consolas", 0, 15)); // NOI18N
        jScrollPane2.setViewportView(ListCartDATicketList);

        LabCartDASTK.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        LabCartDASTK.setText("Stk.");

        LabCartDKType.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        LabCartDKType.setText("Billet type");

        LabCartDKAmountZones.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        LabCartDKAmountZones.setText("Antal zoner");

        LabCartDKPricePerTicket.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        LabCartDKPricePerTicket.setText("Pris pr. stk");

        LabCartDKSubTotal.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        LabCartDKSubTotal.setText("Sub-total");

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(LabCartDAInfo, javax.swing.GroupLayout.PREFERRED_SIZE, 288, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(LabCartDATime, javax.swing.GroupLayout.PREFERRED_SIZE, 309, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(layout.createSequentialGroup()
                        .addGap(44, 44, 44)
                        .addComponent(LabCartDATitle, javax.swing.GroupLayout.PREFERRED_SIZE, 356, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(270, 390, Short.MAX_VALUE)))
                .addContainerGap())
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(ButCartDAHelp)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(ButCartDAClear, javax.swing.GroupLayout.PREFERRED_SIZE, 82, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(84, 84, 84)
                .addComponent(ButCartDARemove, javax.swing.GroupLayout.PREFERRED_SIZE, 81, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(82, 82, 82)
                .addComponent(ButCartDAAddM, javax.swing.GroupLayout.PREFERRED_SIZE, 84, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(71, 71, 71)
                .addComponent(ButCartDAPay, javax.swing.GroupLayout.PREFERRED_SIZE, 107, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(23, 23, 23))
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(LabCartDAInstruct, javax.swing.GroupLayout.PREFERRED_SIZE, 642, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
                        .addGap(115, 115, 115)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 571, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(LabCartDASTK, javax.swing.GroupLayout.PREFERRED_SIZE, 85, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(18, 18, 18)
                                .addComponent(LabCartDKType, javax.swing.GroupLayout.PREFERRED_SIZE, 86, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(47, 47, 47)
                                .addComponent(LabCartDKAmountZones, javax.swing.GroupLayout.PREFERRED_SIZE, 85, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(33, 33, 33)
                                .addComponent(LabCartDKPricePerTicket, javax.swing.GroupLayout.PREFERRED_SIZE, 86, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(26, 26, 26)
                                .addComponent(LabCartDKSubTotal, javax.swing.GroupLayout.PREFERRED_SIZE, 85, javax.swing.GroupLayout.PREFERRED_SIZE)))))
                .addContainerGap(114, Short.MAX_VALUE))
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(LabCartDATotal, javax.swing.GroupLayout.PREFERRED_SIZE, 130, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(129, 129, 129))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(LabCartDAInfo)
                    .addComponent(LabCartDATime))
                .addGap(51, 51, 51)
                .addComponent(LabCartDATitle)
                .addGap(18, 18, 18)
                .addComponent(LabCartDAInstruct)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 30, Short.MAX_VALUE)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(LabCartDASTK)
                    .addComponent(LabCartDKType)
                    .addComponent(LabCartDKAmountZones)
                    .addComponent(LabCartDKPricePerTicket)
                    .addComponent(LabCartDKSubTotal))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 291, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addComponent(LabCartDATotal)
                .addGap(35, 35, 35)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(ButCartDAPay, javax.swing.GroupLayout.PREFERRED_SIZE, 32, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(ButCartDAAddM, javax.swing.GroupLayout.PREFERRED_SIZE, 32, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(ButCartDARemove, javax.swing.GroupLayout.PREFERRED_SIZE, 32, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(ButCartDAClear, javax.swing.GroupLayout.PREFERRED_SIZE, 32, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(ButCartDAHelp, javax.swing.GroupLayout.PREFERRED_SIZE, 32, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(20, 20, 20))
        );
    }// </editor-fold>//GEN-END:initComponents

    private void ButCartDAHelpActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_ButCartDAHelpActionPerformed
        JOptionPane.showMessageDialog(this,
            "\nFor hjælp ring xx xx xx xx"
            + "\nFor teknisk assistance ring xx xx xx xx"
            + "\nHusk at oplyse maskinens ID, som kan findes i øvre venstre hjørne."
            + "\n"
            + "\nBlueJ Trakfikselskab","Hjælp og teknisk support",
            JOptionPane.INFORMATION_MESSAGE);
    }//GEN-LAST:event_ButCartDAHelpActionPerformed

    private void ButCartDAClearActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_ButCartDAClearActionPerformed
        // Clear content of cart-array, list-array, and list
        ListCartDATicketList.removeAll();
        master.CartContent.clear();
        master.SB.clearCart();
        // Reset selectionscreen's inputs
        //master.resetSelectionScreen();
        // Show welcome screen
        //switchWindow(CartDA, WelcomeDA);
    }//GEN-LAST:event_ButCartDAClearActionPerformed

    private void ButCartDARemoveActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_ButCartDARemoveActionPerformed
        int TickToDelete = ListCartDATicketList.getSelectedIndex();
        if (TickToDelete == -1) {        // If no item is selected, escape method call.
            return;
        }
        // Delete string from list-array and Ticket from shopping-array
        master.CartContent.remove(TickToDelete);
        master.SB.removeTicket(TickToDelete);
        // Remake list after deletion
        ListCartDATicketList.setListData(master.CartContent.toArray());
        // Recalculate total price
        LabCartDATotal.setText("Total pris: "+master.SB.getTotalPrice()+" DKK");
    }//GEN-LAST:event_ButCartDARemoveActionPerformed

    private void ButCartDAAddMActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_ButCartDAAddMActionPerformed
        // Reset selectionscreen's inputs
        //master.resetSelectionScreen();
        // Switch to selection window
        //switchWindow(CartDA, WelcomeDA);
    }//GEN-LAST:event_ButCartDAAddMActionPerformed

    private void ButCartDAPayActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_ButCartDAPayActionPerformed
        // If no items in list, abort method call
        if (master.CartContent.isEmpty()) {
            return;
        }
        // Text for machine info label
        //LabPayDAInfo.setText("Maskin ID: "+master.hardID+"  Zone: "+master.startZone);
        // Move to next window
        //switchWindow(CartDA, PayDA);
    }//GEN-LAST:event_ButCartDAPayActionPerformed

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton ButCartDAAddM;
    private javax.swing.JButton ButCartDAClear;
    private javax.swing.JButton ButCartDAHelp;
    private javax.swing.JButton ButCartDAPay;
    private javax.swing.JButton ButCartDARemove;
    private javax.swing.JLabel LabCartDAInfo;
    private javax.swing.JLabel LabCartDAInstruct;
    private javax.swing.JLabel LabCartDASTK;
    private javax.swing.JLabel LabCartDATime;
    private javax.swing.JLabel LabCartDATitle;
    private javax.swing.JLabel LabCartDATotal;
    private javax.swing.JLabel LabCartDKAmountZones;
    private javax.swing.JLabel LabCartDKPricePerTicket;
    private javax.swing.JLabel LabCartDKSubTotal;
    private javax.swing.JLabel LabCartDKType;
    private javax.swing.JList ListCartDATicketList;
    private javax.swing.JScrollPane jScrollPane2;
    // End of variables declaration//GEN-END:variables
}
